<?php
namespace Home\Controller;
use Think\Controller;
class LessonStudentRelationController extends Controller {
    public function index(){
    	

    }
    
    public function _add_lesson_student_relation($orderid){
    	$m = M('YgclOrder');
    	$m_lsr = M('LessonStudentRelation');
    	if(!$m_lsr->where(array('orderid'=>$orderid))->find()){
    		$info = $m->where('id = '.$orderid)->find();
    		$term = M('YgclTerm')->where(array('id'=>$info['termid']))->find();
    		$data = array(
    				'uid' => $info['uid'],
    				'tid' => $info['termid'],
    				'xuenian' => $term['studyyear'],
    				'did' => $info['did'],
    				'cid' => $info['cid'],
    				'lid' => $info['lid'],
    				'student' => $info['stuname'],
    				'tel' => $info['tel'],
    				'jzxm'=> $info['jzxm'],
    				'orderid' => $orderid,
    				'end_time' => $term['end_time'],
    				'student_status' => $info['studentstatus'],
    				'create_time' => Date('Y-m-d H:i:s'),
    				'update_time' => Date('Y-m-d H:i:s'),
    		);
    		$id = $m_lsr->add($data);
    		return $id;
    	}
    }
    
    public function _del_lesson_student_relation($lsid){
    	M('LessonStudentRelation')->where(array('id'=>$lsid))->delete();
    }
    
    public function _add_midbm_info($orderid){
    	$m = M('YgclMidpay');
    	if(!$m->where(array('orderid'=>$orderid))->find()){
    		$info = M('YgclOrder')->where(array('id'=>$orderid))->find();
    		$data = array(
    				'did' => $info['did'],
    				'orderid' =>$orderid,
    				'create_time' => Date('Y-m-d H:i:s'),
    				'update_time' => Date('Y-m-d H:i:s'),
    		);
    		$m->add($data);
    	}
    }
    
}